﻿using Engine.Middlewares;

using Scheduler;

using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Security.Cryptography;

namespace Engine
{
    public class SchedulerBuilder
    {
        public Scheduler.Scheduler BuildScheduler(params object[] ages)
        {
            var ts = new Scheduler.Scheduler();
            var comm = new CommUnitMiddleware();
            const int device = 4;// TODO 配置文件创建设备
         
          
            for (int i = device; i >=0 ; i--)
            {
                var worker = ts.AddWorker(i);
               
                switch (i)
                {
                    case 0:
                        worker.AddMiddleware(comm);
                        worker.AddMiddleware(new VirtualAutoOpticalInspectionMiddleware("192.168.0.10 上料Aoi"));
                        break; 
                    case 1:
                        worker.AddMiddleware(new VirtualSourceMeterUnitMiddleware("192.168.0.11 测试机1"));
                        break;
                    case 2:
                        worker.AddMiddleware(new VirtualSourceMeterUnitMiddleware("192.168.0.12 测试机2"));
                        break;
                    case 3:
                        worker.AddMiddleware(new VirtualSourceMeterUnitMiddleware("192.168.0.14 测试机3"));
                        break;
                 
                    case 4:
                        worker.AddMiddleware(new VirtualAutoOpticalInspectionMiddleware("192.168.0.15 下料Aoi"));

                        // worker.AddMiddleware((Middleware)ages[0]);
                        worker.AddMiddleware(comm);

                        break;


                    default:
                        break;
                }
            }

          
            return ts;
        }
    }
}